//@flow
/**
 * 第三方登陆组件icon
 */
import React, { Component } from 'react';
import { 
    View,
    Text,
 } from 'react-native';
import { ThirpPartType } from "./modal";
import Icon from "react-native-vector-icons/AntDesign";

type Props = ThirpPartType
type State = {
    isShow   :boolean
}
export class ThirdParyIcon extends Component <Props,State>{
    /**初始化state */
    state :State = {
        isShow : false 
    }
    /**生命周期 */
    componentDidMount(){
        if(this.props.installCheckAction){
            this.props.installCheckAction().then(installed=>{
                console.log(`检查平台:${this.props.platform}是否安装结果:${installed}`)
                this.setState({isShow:installed})
            })
        }else{
            console.log('还未配置是否安装的检查方法:'+JSON.stringify(this.props.platform))
        }
    }
    render(){
        if(this.state.isShow){
            return(
                <View
                    style={{flex: 1,alignItems:'center',justifyContent:'center'}}>
                    <Icon 
                        onPress={()=>{
                            alert('icon click')
                        }}
                        color={'white'}
                        name={this.props.iconName}
                        size={30}/>
                </View>
            )
        }else{
            return null
        }
        
    }
}